/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ssp.utility;

/**
 * 任意の2つのオブジェクトを組み合わせたクラス
 * @author yamazaki
 */
public class Pair<A, B> {
    
    private A first;
    
    private B second;
    
    public Pair(Pair pair) {
        this.first = (A)pair.getFirst();
        this.second = (B)pair.getSecond();
    }
    
    public Pair(A first, B second) {
        this.first = first;
        this.second = second;
    }

    public A getFirst() {
        return first;
    }

    public B getSecond() {
        return second;
    }

    public void setFirst(A first) {
        this.first = first;
    }

    public void setSecond(B second) {
        this.second = second;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Pair<A, B> other = (Pair<A, B>) obj;
        if (this.first != other.first && (this.first == null || !this.first.equals(other.first))) {
            return false;
        }
        if (this.second != other.second && (this.second == null || !this.second.equals(other.second))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 59 * hash + (this.first != null ? this.first.hashCode() : 0);
        hash = 59 * hash + (this.second != null ? this.second.hashCode() : 0);
        return hash;
    }
    
}
